package com.sixth.other;

import com.sixth.bean.MarketSystem;
import com.sixth.bean.vo.ConfigExpressVO;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ljh
 * @version 1.0
 * @describition:
 * @since 2022/9/8 14:29
 **/

@Data
public class MarketFreight {
    // market_express_freight_min: "88"
    // market_express_freight_value:
    public static final String marketExpressFreightMin = "market_express_freight_min";
    public static final String marketExpressFreightValue = "market_express_freight_value";
    public static List<String> list;
    static {
        list = new ArrayList<>();
        list.add(marketExpressFreightMin);
        list.add(marketExpressFreightValue);
    }


    public static ConfigExpressVO getConfig(List<MarketSystem> marketSystems) {
        ConfigExpressVO configExpressVO = new ConfigExpressVO();
        for (MarketSystem marketSystem : marketSystems) {
            if (marketExpressFreightMin.equals(marketSystem.getKeyName())) {
                configExpressVO.setMarket_express_freight_min(marketSystem.getKeyValue());
            }
            if (marketExpressFreightValue.equals(marketSystem.getKeyName())) {
                configExpressVO.setMarket_express_freight_value(marketSystem.getKeyValue());
            }

        }
        return configExpressVO;
    }

    public static ConfigExpressVO getConfig(Map<String, Object> map) {
        ConfigExpressVO configExpressVO = new ConfigExpressVO();
        configExpressVO.setMarket_express_freight_value((String) map.get(marketExpressFreightValue));
        configExpressVO.setMarket_express_freight_min((String) map.get(marketExpressFreightMin));
        return configExpressVO;
    }
}
